{% if current_user %}
  <p><a href="{{ current_user.profile_url }}"><img src="http://graph.facebook.com/{{ current_user.id }}/picture?type=square"/></a></p>
  <p>Greetings, {{ current_user.name|escape }}</p>
{% endif %}

<div id="fb-root">
  <fb:user-agent includes="chrome">
    You are using Chrome, yay!
    <embed type="application/x-vnd-cloudspy" id="pluginId"/>
    <script>
      var plugin = document.getElementById("pluginId");
      var process = plugin.attachToProcess();
      console.log("got process: " + process);
    </script>
  </fb:user-agent>
  <fb:user-agent excludes="chrome">
    Chrome is required
  </fb:user-agent>
</div>

<script>
  window.fbAsyncInit = function() {
    FB.init({appId: '{{ facebook_app_id }}', status: true, cookie: true,
             xfbml: true});
    FB.Event.subscribe('{% if current_user %}auth.logout{% else %}auth.login{% endif %}', function(response) {
      window.location.reload();
    });
  };
  (function() {
    var e = document.createElement('script');
    e.type = 'text/javascript';
    e.src = document.location.protocol + '//connect.facebook.net/en_US/all.js';
    e.async = true;
    document.getElementById('fb-root').appendChild(e);
  }());
</script>
